﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

namespace SobrietyEngine.Components.Common
{
    public class ConstantRotationCmp: BaseComponent
    {
        IOrientation orientation = null;
        float yaw = 0, pitch = 0, roll = 0;

        public ConstantRotationCmp()
            : base()
        {
            this.RequiresUpdate = true;
        }

        public ConstantRotationCmp(float _yaw, float _pitch, float _roll):this()
        {
            yaw = _yaw;
            pitch = _pitch;
            roll = _roll;
        }

        public override Boolean InitComponent()
        {
            orientation = Actor.Get<IOrientation>();
            if (orientation == null)
                Logging.Logger.Error(this, "Couldnt locate orientation component");

            return base.InitComponent();
        }

        public override void Update(GameTime elapsedTime)
        {
            if (yaw != 0 || pitch != 0 || roll != 0)
                orientation.WorldAxisYawPitchRoll(yaw, pitch, roll);            
        }
    }
}
